<?php

use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use common\modules\user\models\UserGroup;
use common\modules\system\models\DataDictionary;

/* @var $this yii\web\View */
/* @var $model common\modules\user\models\UserGroup */
/* @var $form yii\bootstrap\ActiveForm */

$groups = UserGroup::find()->all();
?>

<div
	class="user-group-form">

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->errorSummary($model); ?>
    
    <?= $form->field($model, 'parent_id')->dropDownList(\yii\helpers\ArrayHelper::map($groups, 'id', 'name'), [
        'prompt' => ''
    ])?>

    <?= $form->field($model, 'type')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'description')->textarea(['rows' => 6]) ?>
    
    <?= $form->field($model, 'group_rank')->dropDownList(\yii\helpers\ArrayHelper::map(DataDictionary::getChildren('group_rank', 0), 'value', 'name'), [
        'prompt' => ''
    ])?>

    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
